home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / thesource6.dms / thesource6.adf / Source / Compression / hcompress.lha / hcompress / unix / fcompress.csh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1992-04-21  |  1.8 KB  |  72 lines

  1. #! /bin/csh
  2. # Shell file to do H-transform image compression for a list of image files
  3. # in FITS format.  Files are replaced by <name>.H.
  4. #
  5. # Program will compress only I*2 images with no group parameters.
  6. # (A warning is issued for other images.)
  7. #
  8. # The default compression scale factor is 666, which is appropriate for
  9. # GASP images (gives about a factor of 10 compression, negligible loss in
  10. # information.)
  11. #
  12. # R. White, 20 April 1992
  13. set noclobber
  14. set shellfile=$0
  15. set cdir=`dirname $shellfile`
  16. set prgnam=${shellfile:t}
  17. #
  18. if ($#argv == 0) then
  19.     echo "Usage: ${prgnam} [options] files... [options] files..."
  20.     echo "  where options are:"
  21.     echo "     -s scale to specify the compression scale factor"
  22.     echo "     -k       to keep the uncompressed file (default)"
  23.     echo "     -r       to remove the uncompressed file"
  24.     echo
  25.     echo "Default compression scale factor is 666 (good for GASP images.)"
  26.     echo "Compressed files are named *.*.H."
  27.     exit
  28. endif
  29. set scale=666
  30. set nextscale=0
  31. set remove=0
  32. foreach parm ($*)
  33.     if ($nextscale) then
  34.         set scale=$parm
  35.         set nextscale=0
  36.         echo Using scale $scale
  37.     else
  38.         if ("$parm" == "-s") then
  39.             set nextscale=1
  40.         else if ("$parm" == "-r") then
  41.             set remove=1
  42.         else if ("$parm" == "-k") then
  43.             set remove=0
  44.         else
  45.             set datafile="$parm"
  46.             set compfile="${datafile}.H"
  47.             if (-e $compfile) then
  48.                 echo "${prgnam}: $compfile already exists"
  49.             else if (! -e $datafile) then
  50.                 echo "${prgnam}: ${datafile}: No such file"
  51.             else
  52.                 #
  53.                 # do the compression
  54.                 #
  55.                 echo -n "$datafile "
  56.                 $cdir/hcomp -v -s $scale -i fits $datafile \
  57.                     > $compfile
  58.                 if ($status == 0) then
  59.                   if ($remove) then
  60.                     # delete original file
  61.                     /bin/rm $datafile
  62.                   endif
  63.                 else
  64.                   echo "${prgnam}: $datafile not compressed: compression error"
  65.                   /bin/rm $compfile
  66.                 endif
  67.             endif
  68.         endif
  69.     endif
  70. end
  71.